iT邦幫忙

2024 iThome 鐵人賽

DAY 8
0
Mobile Development

從零開始學習 Jetpack Compose系列 第 8

從零開始學習 Jetpack Compose Day7 - Image

  • 分享至 

  • xImage
  •  

Image

在畫面上顯示圖片的元件,但需要先把要顯示的圖檔放在專案資料夾的resources裡面,如果要使用網路圖片就必須使用第三方套件,如:Glide、Coil。

Painter:設定圖片

透過painterResource來設定顯示的圖片
https://raw.githubusercontent.com/jian-fu-hung/ithelp-2024/refs/heads/main/Images/Day7/%E6%88%AA%E5%9C%96%202024-09-22%20%E6%99%9A%E4%B8%8A9.28.44.png

ContentScale:圖片縮放

ContentScale.Fit:等比例縮放

ContentScale.Crop:裁減滿版

ContentScale.Inside:等比例縮放,如果圖片本身就小於外框則處理縮放。

ContentScale.FillBounds:垂直和水平非均勻縮放內容

ContentScale.None:不做縮放,如果圖片大於外框則裁切
https://raw.githubusercontent.com/jian-fu-hung/ithelp-2024/refs/heads/main/Images/Day7/%E6%88%AA%E5%9C%96%202024-09-22%20%E6%99%9A%E4%B8%8A9.30.26.png

Alpha:圖片透明度

https://raw.githubusercontent.com/jian-fu-hung/ithelp-2024/refs/heads/main/Images/Day7/%E6%88%AA%E5%9C%96%202024-09-22%20%E6%99%9A%E4%B8%8A9.30.49.png


上一篇
從零開始學習 Jetpack Compose Day6 - Button
下一篇
從零開始學習 Jetpack Compose Day8 - Column、Row與Box
系列文
從零開始學習 Jetpack Compose12
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言